import fetch from 'utils/fetch';

export function page(query) {
  return fetch({
    url: '/api/role/page',
    method: 'get',
    params: query
  });
}
export function add(obj) {
  const role = {
    roleName: obj.roleName,
    description: obj.description,
    status: obj.status,
    id: obj.id == undefined ? null : obj.id
  }
  const data = {
    role: role,
    menuIds: obj.menuIds
  }
  return fetch({
    url: '/api/role/add',
    method: 'post',
    data
  })
}
export function getMenuTree() {
  return fetch({
    url: '/api/user/front/menus'
  })
}
export function getRoleMenu(roleId) {
  return fetch({
    url: '/api/role/getRoleMenu',
    params: { 'roleId': roleId }
  })
}

export function getRoles() {
  return fetch({
    url: '/api/role/getRoles',
    method: 'get'
  })
}

